# Table B.3: Effect of Ordered Net Benefits on Administrative Turnout


# 1. Load Packages ----

library(stargazer)
library(lfe)

# 2. Read in Data ----

load(file = "df_voxit_prop_canton.RData")

# 3. Regressions ----
##  I) Ordered Propositions ----

# reg1
lm.rob1 <- felm(turnout_admin ~ utility_prop_1st + 
                  avg_male + avg_married + 
                  avg_age + avg_uni + avg_knowledge + avg_leftright | 
                  0 | 0 | canton_id + datum_merge, 
                data = voxit_prop_canton[voxit_prop_canton$prop_voxit==1 ,])
summary(lm.rob1)

# reg2
lm.rob2 <- felm(turnout_admin ~ utility_prop_1st + utility_prop_2nd + 
                  avg_male + avg_married + 
                  avg_age + avg_uni + avg_knowledge + avg_leftright | 
                  0 | 0 | canton_id + datum_merge, 
                data = voxit_prop_canton[voxit_prop_canton$prop_voxit==2 ,])
summary(lm.rob2)

# reg3
lm.rob3 <- felm(turnout_admin ~ utility_prop_1st + utility_prop_2nd + utility_prop_3rd + 
                  avg_male + avg_married + 
                  avg_age + avg_uni + avg_knowledge + avg_leftright | 
                  0 | 0 | canton_id + datum_merge, 
                data = voxit_prop_canton[voxit_prop_canton$prop_voxit==3 ,])
summary(lm.rob3)


# 4. Regression Table ----
stargazer(lm.rob1, lm.rob2, lm.rob3,
          type = "latex", star.cutoffs = c(0.1, 0.05, 0.01),
          star.char = c("*", "**", "***"),
          summary=T, df = F, float = F,
          keep = c("^utility_prop"),
          covariate.labels = c("U$^{1st}$ ", "U$^{2nd}$",
                               "U$^{3rd}$"),
          dep.var.caption="Dependent variable: Turnout",
          add.lines = list(c("\\# of propositions", "1", "2", "3"),
                           c("\\# of voting days", 
                             length(unique(voxit_prop_canton[voxit_prop_canton$prop_voxit==1,]$datum_merge)),
                             length(unique(voxit_prop_canton[voxit_prop_canton$prop_voxit==2,]$datum_merge)),
                             length(unique(voxit_prop_canton[voxit_prop_canton$prop_voxit==3,]$datum_merge)))),
          dep.var.labels.include=F,
          omit.table.layout ="n",
          keep.stat = c("n"),
          out = "TableB3.tex")

